Skip to content

fix(oss-licenses-plugin): sanitize newlines in Dependency.name to prevent metadata injection - #461

Open
timothyfroehlich wants to merge 1 commit into
mainfrom
froeht/fix-newline-injection
Open

fix(oss-licenses-plugin): sanitize newlines in Dependency.name to prevent metadata injection#461
timothyfroehlich wants to merge 1 commit into
mainfrom
froeht/fix-newline-injection

Conversation

@timothyfroehlich

Copy link
Copy Markdown
Member

Strip CR/LF characters and trim whitespace in Dependency constructor, and make key/name final to prevent Groovy setter bypass.

@timothyfroehlich
timothyfroehlich force-pushed the froeht/fix-newline-injection branch from 2172a66 to fe25d93 Compare September 9, 2026 19:21
@timothyfroehlich
timothyfroehlich force-pushed the froeht/fix-newline-injection branch from fe25d93 to 88b5b04 Compare September 9, 2026 19:57
String expected =
"0:8 Dependency 1 0:120 Forged Entry"
+ LINE_BREAK
+ "9:8 Dependency 2 Spoofed"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider calculate the second offset dynamically to avoid issues on different OS.

this.key = Objects.requireNonNull(key, "key cannot be null")
this.name = Objects.requireNonNull(name, "name cannot be null")
.replaceAll(/\R+/, ' ')
.strip()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider defaulting to key if name becomes empty after sanitization.

Dependency(String key, String name) {
this.key = key
this.name = name
this.key = Objects.requireNonNull(key, "key cannot be null")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key should be sanitized as well?

@timothyfroehlich
timothyfroehlich force-pushed the froeht/fix-newline-injection branch from 88b5b04 to d30bce0 Compare September 10, 2026 22:19
…vent metadata injection

Strip CR/LF characters and trim whitespace in Dependency constructor, and make key/name final to prevent Groovy setter bypass.

BUG=557266592

CONV=b20a8ae9-55d6-4655-87f8-edba5da5028b

TAG=agy
@timothyfroehlich
timothyfroehlich force-pushed the froeht/fix-newline-injection branch from d30bce0 to 37bc025 Compare September 10, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants